package com.zl.hyzg.controller;

import com.zl.hyzg.domain.User;
import com.zl.hyzg.service.LoginService;
import com.zl.hyzg.util.MD5Utils;
import com.zl.hyzg.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class LoginController {
    @Autowired
    private LoginService loginService;
    @PostMapping("/login")
    public String login(@RequestBody UserVo userVo){
        userVo.setPassword(MD5Utils.setPwd(userVo.getPassword()));
        System.out.println(userVo);
       User user = loginService.login(userVo);
       if(user==null){
           return "fail";
       }else{
           return "success";
       }
    }
}
